package com.practicesuite.systemlayer;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Admin extends User implements Serializable {
    public Admin() {
        
    }
   
    
    public Admin(String name, int eUID, int userID, Date dateOfBirth, String address, String phoneNumber, 
            String gender, int age, String emailAddress, boolean suspended) {
        super(name, eUID, userID, dateOfBirth, address, phoneNumber, gender, age, emailAddress, suspended);
    }
    
    /**
     * 
     * 
     * @param u The current user object you wish to create
     * @param id The id "type" associated with the user object (i.e. 0 = admin, 1 =doctor etc)
     * @param userName Users desired UserName
     * @param passWord Users desired password
     * @param a The current Admin object you are working with when creating this user, needs to be passed
     * to verify that they are indeed an admin object
     * @return
     */
    public int addUser(User u, int id, String userName, String password, Admin a) {
        
        if(id == 0) {
            Admin admin = (Admin)u;
            try {
                return SystemDriver.createUser(admin.getName(), admin.getDateOfBirth()
                        , admin.getAddress(), admin.getPhoneNumber(), admin.getGender()
                        , admin.getAge(), admin.getEmail()
                        , userName, password.toCharArray(), a, id);
                
            } catch (Exception e) {
              
                return 0;
            }
        }
        else if(id == 1) {
            Doctor d = (Doctor)u;
            try {
                return SystemDriver.createUser(d.getName(), d.getDateOfBirth(), d.getAddress(), d.getPhoneNumber()
                        , d.getGender(), d.getAge(), d.getEmail()
                        , userName, password.toCharArray()
                        , a, id);
            } catch (Exception e) {
                return 0;
            }
        }
        else if(id == 2) {
            Nurse n = (Nurse)u;
            try {
                return SystemDriver.createUser(n.getName(), n.getDateOfBirth(), n.getAddress()
                        , n.getPhoneNumber(), n.getGender(), n.getAge()
                        , n.getEmail(), userName, password.toCharArray(), a, id);
            } catch (Exception e) {
                return 0;
            }
        }
        else {
            Patient p = (Patient)u;
            
             try {
                SystemDriver.createPatient(p.getName(), p.getDateOfBirth()
                        , p.getAddress(), p.getPhoneNumber(), p.getGender()
                        , p.getAge(), p.getEmail(), userName, password.toCharArray()
                        , p.getEUID(), p.getMedicalInformation());
                return 1;
            } catch (Exception e) {
                return 0;
            }
        }
        
        
       
            
            
            

    }
    
    /**
     * Delete user from system
     * @param loginID loginid associated with user
     * @param a Your admin object to ensure authentication
     * @return Returns status, 0 is a fail, 1 is a success
     */
    public int deleteUser(int loginID, Admin a) {
        try {
            return SystemDriver.deleteUser(loginID);
        } catch (Exception e) {
            return 0;
        }
    }
    

}
